package io.renren.modules.aic.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import io.renren.modules.aic.entity.BalanceTopupEntity;
import io.renren.modules.aic.service.BalanceTopupService;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户充值表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-03-30 15:44:18
 */
@RestController
@RequestMapping("aic/balancetopup")
public class BalanceTopupController {
	@Autowired
	private BalanceTopupService balanceTopupService;

	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("aic:balancetopup:list")
	public R list(@RequestParam Map<String, Object> params) {
		PageUtils page = balanceTopupService.queryPage(params);

		return R.ok().put("page", page);
	}

	/**
	 * 保存
	 */
	@SysLog("会员充值")
	@RequestMapping("/save")
	@RequiresPermissions("aic:balancetopup:save")
	public R save(@RequestBody BalanceTopupEntity balanceTopup) {
		// 校验类型
		ValidatorUtils.validateEntity(balanceTopup);

		balanceTopupService.save(balanceTopup);

		return R.ok();
	}
}
